package cn.stylefeng.guns.modular.business.frequency.orderinsurance.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.orderinsurance.service.OrderInsuranceService;
import cn.stylefeng.guns.modular.business.frequency.orderinsurance.model.param.OrderInsuranceParam;

import javax.annotation.Resource;

/**
 * 订单生成保单合同表 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:16
 */
@RestController
public class OrderInsuranceController {

    @Resource
    private OrderInsuranceService orderInsuranceService;

    /**
     * 分页查询订单生成保单合同表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderInsurance/page")
    @BusinessLog(title = "订单生成保单合同表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(OrderInsuranceParam orderInsuranceParam) {
        return new SuccessResponseData(orderInsuranceService.page(orderInsuranceParam));
    }

    /**
     * 获取全部订单生成保单合同表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderInsurance/list")
    @BusinessLog(title = "订单生成保单合同表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(OrderInsuranceParam orderInsuranceParam) {
        return new SuccessResponseData(orderInsuranceService.list(orderInsuranceParam));
    }

    /**
     * 查看详情订单生成保单合同表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @GetMapping("/orderInsurance/detail")
    @BusinessLog(title = "订单生成保单合同表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(OrderInsuranceParam.detail.class) OrderInsuranceParam orderInsuranceParam) {
        return new SuccessResponseData(orderInsuranceService.detail(orderInsuranceParam));
    }

    /**
     * 添加订单生成保单合同表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderInsurance/add")
    @BusinessLog(title = "订单生成保单合同表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(OrderInsuranceParam.add.class) OrderInsuranceParam orderInsuranceParam) {
        orderInsuranceService.add(orderInsuranceParam);
        return new SuccessResponseData();
    }

    /**
     * 删除订单生成保单合同表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderInsurance/delete")
    @BusinessLog(title = "订单生成保单合同表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(OrderInsuranceParam.delete.class) OrderInsuranceParam orderInsuranceParam) {
        orderInsuranceService.delete(orderInsuranceParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑订单生成保单合同表
     *
     * @author yujie
     * @date 2023/05/09 17:16
     */
    @PostMapping("/orderInsurance/edit")
    @BusinessLog(title = "订单生成保单合同表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(OrderInsuranceParam.edit.class) OrderInsuranceParam orderInsuranceParam) {
        orderInsuranceService.edit(orderInsuranceParam);
        return new SuccessResponseData();
    }


}
